package cn.ratel.exception;

public class RatelException extends RuntimeException {

	private Cause causeType;

	public RatelException(Cause causeType, Throwable cause) {
		super(cause);
		this.causeType = causeType;
	}

	public RatelException(String message, Cause causeType, Throwable cause) {
		super(message, cause);
		this.causeType = causeType;
	}

	public RatelException(String message, Cause causeType) {
		super(message);
		this.causeType = causeType;
	}

	public RatelException(Cause causeType) {
		super(causeType.getInfo());
		this.causeType = causeType;
	}

	public Cause getCauseType() {
		return causeType;
	}

	public enum Cause {
		_404(404, "page not found error"),
		_403(403, "Forbidden error"),
		_401(401, "unauthorized error"),
		_500(500, "500 error");

		private int code;
		private String info;

		Cause(int code, String info) {
			this.code = code;
			this.info = info;
		}

		public int getCode() {
			return code;
		}

		public String getInfo() {
			return info;
		}

	}
}
